package com.example.newbilityblog.admin.service;

import com.example.newbilityblog.admin.api.response.AdminUserResponse;
import com.example.newbilityblog.admin.infrastructure.repository.AdminUserRepository;
import com.example.newbilityblog.admin.service.mapper.AdminUserMapper;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Service;

@Service
public class AdminUserService {
    private final AdminUserRepository adminUserRepository;
    private final AdminUserMapper mapper;

    public AdminUserService(AdminUserRepository adminUserRepository) {
        this.adminUserRepository = adminUserRepository;
        this.mapper = Mappers.getMapper(AdminUserMapper.class);
    }

    public AdminUserResponse findByUsernameAndPassword(String username, String password) {
        return mapper.toAdminUserResponse(
                adminUserRepository.findByUsernameAndPassword(username, password)
                        .orElse(null));
    }
}
